'use strict'

class draft {
  constructor() {
    this.param = '/'
  }

  async get(c) {

    let {user_id} = c.query;

    let a = c.service.fun;

    c.setHeader('content-type', 'text/html; charset=utf-8');

    //let {draft_txt}

    let data =await a.sel('draft_list',{"draft_user_id":user_id},["draft_txt","draft_title","draft_time","draft_img"],c.service.pool)
    console.log(data.rows)
      try{
     let dataobj = data.rows[0];
     //let {draft_title,draft_time,draft_img,draft_txt} = data.rows[0];
     c.send({
      type:'object',
      data:dataobj
     })
     a.del('draft_list',{"draft_user_id":user_id},c.service.pool)
    }catch(e){
     let draft_txt = '无草稿' ;
     c.send({
      type:'err',
      data:draft_txt
     })
    }

  }


}
module.exports = draft;

